%h3.page-title
  用户:
  = @user.name
  - if @user.blocked?
    %span.cred (已禁用)
  - if @user.admin
    %span.cred (管理员)

  .pull-right
    = link_to edit_admin_user_path(@user), class: "btn grouped" do
      %i.icon-edit
      修改
    - if @user.blocked?
      = link_to '解禁', unblock_admin_user_path(@user), method: :put, class: "btn grouped success"
%hr

.row
  .span6
    .ui-box
      .title
        描述:
        .pull-right
          = image_tag gravatar_icon(@user.email, 32), class: "avatar s32"
      %ul.well-list
        %li
          %span.light Name:
          %strong= @user.name
        %li
          %span.light Username:
          %strong
            = @user.username
        %li
          %span.light Email:
          %strong
            = mail_to @user.email
        %li
          %span.light 是否能创建"用户组":
          %strong
            = @user.can_create_group ? "Yes" : "No"
        %li
          %span.light 创建项目数最多:
          %strong
            = @user.projects_limit
        %li
          %span.light 创建时间:
          %strong
            = @user.created_at.stamp("Nov 12, 2031")

        %li
          %span.light 最后登录时间:
          %strong
            - if @user.last_sign_in_at
              = @user.last_sign_in_at.stamp("Nov 12, 2031")
            - else
              never

        - if @user.ldap_user?
          %li
            %span.light LDAP uid:
            %strong
              = @user.extern_uid

        - if @user.created_by
          %li
            %span.light Created by:
            %strong
              = link_to @user.created_by.name, [:admin, @user.created_by]

    - unless @user == current_user
      .alert
        %h4 Block user
        %br
        %p Blocking user has the following effects:
        %ul
          %li User will not be able to login
          %li User will not be able to access git repositories
          %li User will be removed from joined projects and groups
          %li Personal projects will be left
          %li Owned groups will be left
        = link_to 'Block user', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-remove"

      .alert.alert-error
        %h4
          Remove user
        %br
        %p Deleting a user has the following effects:
        %ul
          %li All user content like authored issues, snippets, comments will be removed
          - rp = @user.personal_projects.count
          - unless rp.zero?
            %li #{pluralize rp, 'personal project'} will be removed and cannot be restored
          - if @user.solo_owned_groups.present?
            %li
              Next groups with all content will be removed:
              %strong #{@user.solo_owned_groups.map(&:name).join(', ')}
        = link_to 'Remove user', [:admin, @user], confirm: "USER #{@user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-remove"

  .span6
    - if @user.users_groups.present?
      .ui-box
        .title 所属用户组:
        %ul.well-list
          - @user.users_groups.each do |user_group|
            - group = user_group.group
            %li.users_group
              %strong= link_to group.name, admin_group_path(group)
              .pull-right
                %span.light= user_group.human_access
                - unless user_group.owner?
                  = link_to group_users_group_path(group, user_group), confirm: remove_user_from_group_message(group, @user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
                    %i.icon-remove.icon-white

    .ui-box
      .title 项目 (#{@projects.count})
      %ul.well-list
        - @projects.sort_by(&:name_with_namespace).each do |project|
          - tm = project.team.find_tm(@user.id)
          %li.users_project
            = link_to admin_project_path(project), class: dom_class(project) do
              - if project.namespace
                = project.namespace.human_name
                \/
              %strong.well-title
                = truncate(project.name, length: 45)

            - if tm
              .pull-right
                - if tm.owner?
                  %span.light Owner
                - else
                  %span.light= tm.human_access

                  - if tm.respond_to? :project
                    = link_to project_team_member_path(project, @user), confirm: remove_from_project_team_message(project, @user), remote: true, method: :delete, class: "btn-tiny btn btn-remove", title: '从这个项目中移除掉Ta' do
                      %i.icon-remove


